import { Badge, Popconfirm, Space, TableColumnsType, Tag, Tooltip, Typography } from 'antd'
import { NavigateFunction } from 'react-router-dom'
import type { ITableData, ITableDataRoleList } from './types'
import { DIS_STATUSBANDBTNTEXT, STATUSBAND, USERTYPETEXT } from '@/constant'
export const useIndexColumns = (
  onEdit: (info: ITableData) => void,
  onShowModal: (info: ITableData) => void,
  onDel: (info: ITableData) => void,
  params: Record<string, any>,
): TableColumnsType<ITableData> => [
  {
    title: '字典名称',
    dataIndex: 'dictName',
    key: 'dictName',
    align: 'center',
    render: (info) => {
      return info ? info : '-'
    },
  },
  {
    title: '字典类型',
    dataIndex: 'dictType',
    key: 'dictType',
    align: 'center',
    render: (info) => {
      return info ? info : '-'
    },
  },
  {
    title: '字典描述',
    dataIndex: 'remark',
    key: 'remark',
    align: 'center',
    width: 200,
    render: (info) => {
      return info ? info : '-'
    },
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
    align: 'center',
    render: (info) => {
      return <Badge status={info == 1 ? 'success' : 'error'} text={STATUSBAND[info] || '-'} />
    },
  },
  {
    fixed: 'right',
    title: '操作',
    width: 250,
    align: 'center',
    render: (info) => {
      return (
        <Space size="large">
          <Typography.Link onClick={() => onEdit(info)}>编辑</Typography.Link>
          <Typography.Link onClick={() => onShowModal(info)}>字典数据</Typography.Link>
          <Popconfirm title={`确认删除吗？`} onConfirm={() => onDel(info)} okText="确认" cancelText="取消">
            <Typography.Link type="danger">删除</Typography.Link>
          </Popconfirm>
        </Space>
      )
    },
  },
]
